package com.bric.sqlFile;

import java.io.File;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ThreadPoolExecutor;

import org.apache.log4j.Logger;

import com.bric.util.StaticStr;
import com.bric.util.ThreadPools;

public class SqlFile extends Thread{
	public static Queue<File> Filequeue=new ConcurrentLinkedQueue<File>();
	private static final Logger log=Logger.getLogger(SqlFile.class);
	@Override
	public void run() {
		log.info("将sql文件解析执行的线程开始...");
		File sqlFile=new File(StaticStr.localFilePath+StaticStr.sqlFilePath);
		getFile(sqlFile);
		ThreadPoolExecutor excutor=ThreadPools.getSingleton().getTheadPools();
		ExcuteSql sql=new ExcuteSql();
		Thread t1=new Thread(sql);
		Thread t2=new Thread(sql);
		Thread t3=new Thread(sql);
		Thread t4=new Thread(sql);
		excutor.execute(t1);
		excutor.execute(t2);
		excutor.execute(t3);
		excutor.execute(t4);
	}
	void getFile(File file){
		if(file.exists()&&file.isDirectory()){
			File[] files=file.listFiles();
			for(File f:files){
				if(f.isDirectory()){
					getFile(f);
				}else{
					Filequeue.add(f);
				}
			}
		}
	}
}
